<template>
  <div class="component">
    <div class="list">
        <div class="item" @click="goDetail()" v-for="(item,index) in list" :key="index">
            <img :src="item.imgUrl" alt="">
            <div class="name">{{item.name}}</div>
        </div>
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
// 接受父组件传递的参数
const props = defineProps({
  list: { 
    type: Array,
    default: [],
  },
 
});
const goDetail = () => {
  router.push("/detail");
};
const router = useRouter();
onMounted(() => {});
</script>
<style scoped lang="less">
.list{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0 10px;
    .item{
        width: 38%;
        background: #fff;
        margin: 10px 5px;
        padding: 15px;
        border-radius: 5px;
        img{
            width: 120px;
        }
    }
}
</style>
